home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
mouse.exe
/
MOUSE.DOC
< prev
next >
Wrap
Text File
|
1989-06-03
|
56KB
|
1,357 lines
MOUSE V3.1
as of 28 May 1989
Author: Michael Day
This program is released to the public domain by the author.
Mouse has gone through a number of major rewrites since it
was originally introduced. This latest release has changed the way
some of the functions work. If you are using the old mouse
program, you will most likely have to make some minor changes to
your program to use this new version of Mouse.
The most significant difference is how the mouse positioning
is being handled now. In the earlier Mouse program there were
separate routines for the text and graphics mouse positioning,
and separate variables. This is no longer the case. The double
routines have been merged into single routines with a flag to
(TextMouse) control whether the position data is treated as text
positioning or graphics positioning. Further, new functions have
been added to convert the virtual position information provided
by the mouse back to real screen positioning needed by programs.
To properly set the mouse position, or read the position of
the mouse, you should now use the translation functions to
correctly derive the proper mouse position on the screen. The
advantage to this is that the translation routines are
intelligent enough to be able to properly convert the positioning
information based on the current display type and mode. The
standard CGA, EGA, VGA, and Hercules displays and their modes are
supported. Note: most mouse drivers do not support extended or
non-standard display modes. You may need to override the mouse
position translator with your own if you use a non-standard mode.
The other big change is the addition of the simulated mouse
cursor. Why a simulated mouse cursor? Two reasons, one, if you
don't have a mouse, you can still make believe that you do by
using the simulated cursor and keyboard input. And two, it gets
around a problem with Turbo Pascal in that it is not well behaved
when it comes to mice. Turbo Pascal and the Turbo Debugger will
trash the mouse cursor when using the standard mouse driver to
generate the cursor. You can get around this by using the
simulated cursor instead. Since it operates via the program,
Turbo Pascal and Turbo Debugger are happy. There is one
disadvantage though, if the simulated mouse is used the cursor
operation will be slow and jerky. I recommend that you continue
to use the driver generated mouse cursor for commercial
applications where possible. The simulated mouse is mainly to
allow you to use a mouse while debugging a program or to run a
program without a mouse at all.
ISR Support:
Another addition is ISR support for the mouse so that you
don't have to sprinkle ReadMouse calls through out your program.
This can make mouse programming much simpler.
Graphic Mouse Cursor:
There are 19 supplied Graphic mouse cursors in the program.
You can select the desired cursor by calling the
MouseGraphicCursor function which will cause the selected cursor
to be loaded from the table. You can see which cursor has been
loaded by looking at the global MouseGStyle variable. If
MouseGStyle contains a -1 it means that a custom cursor has been
loaded. You can load your own custom graphic mouse cursor by
using the SetMouseGraphicCursor function.
Text Mouse Cursor:
There are 16 supplied Text mouse cursors in the program. You
can select the desired cursor by calling the MouseTextCursor
function which will cause the selected cursor to be loaded from
the table. You can see which cursor has been loaded by looking at
the global MouseTStyle variable. If MouseTStyle contains a -1 it
means that a custom cursor has been loaded. If MouseTStyle
contains a 0, then the current hardware cursor is used. You can
load your own custom text mouse cursor by using the
SetMouseTextCursor function.
The TextMouse flag is used to identified whether the mouse
is currently in text or graphics mode. Calling the MouseInit
procedure will cause the TextMouse flag to be set based on the
value found in the BIOS CrtMode flag.
if you are using a non-standard or extended display mode
(graphic or text), the mouse position translation routines may
not be able to correctly translate the screen position to the
virtual mouse position used by the mouse driver. You can however
override the mouse position control variables after calling
InitMouse to perform your own translation.
Mouse Installation:
The Mouse program expects a MicroSoft or compatible mouse
driver to be installed on the computer. All mouse operations are
performed through the mouse interrupt ($33). For more information
on using the mouse interrupt refer to the MicroSoft Mouse
Programmer's Reference Guide available from MicroSoft or though
various computer book stores.
If the mouse driver has not been installed, then the
InitMouse procedure will set the MouseInstalled flag to false and
most mouse procedures will immediately terminate if called. The
basic mouse functions will continue to operate however if your
program updates the MouseX and MouseY mouse positioning
variables. This allows keyboard mouse emulation if the mouse is
not available.
Starting out:
The first thing to do to get the mouse going is to call the
InitMouse function near the beginning of your program before you
use the other mouse functions.
The InitMouse function initailizes the mouse driver to a
predefined state. You can call the InitMouse function at anytime,
but you should realize that any previous state will be lost.
Special note about Hercules:
If you are using a Hercules display, then you must
call the SetHercMouse function before calling the InitMouse
function. This is because the mouse driver must know which
display page and mode of the Hercules card you are using.
Also be sure to call the SetHercMouse function with a -1 to
return it to text mode when you switch back to text mode.
An exit procedure has been provided in Mouse which will
properly restore the function when you exit your program.
The reason for this special handling is that the
hercules card does not provide any way for the system to
know if it is in text mode or graphics mode, and if in
graphics mode which page is selected. As such, this
information must be maintain by the user program. The
MicroSoft mouse driver uses the CrtMode variable to find
this information and leaves it up to the user program to
properly set the variable for desired operation.
Showing the Mouse:
Once you have the mouse initialized, You can make it appear
on the screen by calling the ShowMouse function.
If the mouse was previously hidden, you must call ShowMouse
the same number of times that you called HideMouse to get the
mouse to appear.
Hiding the Mouse:
To hide the mouse cursor you call the HideMouse function.
You can call the HideMouse function multiple times. If the mouse
is currently visible it will be immediately hidden. If the mouse
cursor is not visible then a counter is decremented. To make the
mouse visible again you must call ShowMouse the same number (or
more) times as you called HideMouse.
Remember that InitMouse will always restore the mouse to the
first hidden level requiring only a single call to ShowMouse to
make the mouse cursor visible.
Hiding the mouse does not disable the mouse, it only causes
the mouse cursor to not be displayed. All mouse functions are
still fully operational. If the mouse is moved the mouse position
will be updated even if the